import Vue from 'vue'
import Router from 'vue-router'

Vue.use(Router)

/* Layout */
import Layout from '@/layout'

export const constantRoutes = [
  {
    path: '/login',
    component: () => import('@/views/login/index'),
    hidden: true
  },
  {
    path: '/404',
    component: () => import('@/views/error/404.vue'),
    hidden: true
  },
  {
    path: '*',
    redirect: '/404',
    hidden: true
  },
  {
    path: '/',
    component: Layout,
    redirect: '/Fourth/LeaderHome'
  },
  // 重定向
  {
    path: '/redirect',
    component: Layout,
    hidden: true,
    children: [
      {
        path: '/redirect/:path(.*)',
        component: () => import('@/views/redirect')
      }
    ]
  },
  {
    path: '/one',
    component: Layout,
    meta: { title: '第一版', icon: 'dashboard' },
    children: [
      {
        path: 'Home',
        component: () => import('@/views/Home'),
        name: 'Home',
        meta: { title: '首页', icon: 'dashboard' }
      },
      {
        path: 'TaskIssued',
        component: () => import('@/views/TaskIssued'),
        name: 'TaskIssued',
        meta: { title: '任务下发', icon: 'dashboard' }
      },
      {
        path: 'TaskLedger',
        component: () => import('@/views/TaskLedger'),
        name: 'TaskLedger',
        // affix 标题不可关闭
        meta: { title: '任务台账', icon: 'dashboard', affix: true }
      },
      {
        path: 'TaskDetails',
        component: () => import('@/views/TaskDetails'),
        name: 'TaskDetails',
        meta: { title: '任务明细', icon: 'dashboard' }
      },
      {
        path: 'FillPage',
        component: () => import('@/views/TaskDetails/FillPage.vue'),
        name: 'FillPage',
        meta: { title: '填报页面', icon: 'dashboard' }
      },
      {
        path: 'FillPageV',
        component: () => import('@/views/TaskDetails/FillPageV.vue'),
        name: 'FillPageV',
        meta: { title: '填报页面浏览', icon: 'dashboard' }
      },
      {
        path: 'FillPage2',
        component: () => import('@/views/TaskDetails/FillPage2.vue'),
        name: 'FillPage2',
        meta: { title: '填报页面2', icon: 'dashboard' }
      },
      {
        path: 'LedgerDetails',
        component: () => import('@/views/TaskLedger/LedgerDetails.vue'),
        name: 'LedgerDetails',
        meta: { title: '台账明细', icon: 'dashboard' }
      },
      {
        path: 'MonthlyBreakdown',
        component: () => import('@/views/TaskLedger/MonthlyBreakdown.vue'),
        name: 'MonthlyBreakdown',
        meta: { title: '月度明细', icon: 'dashboard' }
      },
      {
        path: 'Approval',
        component: () => import('@/views/Approval/Approval.vue'),
        name: 'Approval',
        meta: { title: '审批', icon: 'dashboard' }
      }
    ]
  },

  {
    path: '/tow',
    component: Layout,
    meta: { title: '第二版', icon: 'dashboard' },
    children: [
      {
        path: 'zidingyibiaoto',
        component: () => import('@/views/renwuxiafaxin/zidingyibiaoto.vue'),
        name: 'zidingyibiaoto',
        meta: { title: '填报页面-表头', icon: 'dashboard' }
      },
      {
        path: 'tianbao',
        component: () => import('@/views/renwuxiafaxin/tianbao.vue'),
        name: 'tianbao',
        meta: { title: '填报页面2', icon: 'dashboard' }
      },
      {
        path: 'home2',
        component: () => import('@/views/renwuxiafaxin/home.vue'),
        name: 'home2',
        meta: { title: '首页2', icon: 'dashboard' }
      }
    ]
  },
  {
    path: '/Three',
    component: Layout,
    meta: { title: '第三版', icon: 'dashboard' },
    children: [
      {
        path: 'DepLeaderHome',
        component: () => import('@/views/ThreeEdition/LeaderHome.vue'),
        name: 'DepLeaderHome',
        meta: { title: '领导首页', icon: 'dashboard' }
      },
      {
        path: 'EmployeeHome',
        component: () => import('@/views/ThreeEdition/EmployeeHome.vue'),
        name: 'EmployeeHome',
        meta: { title: '待办首页', icon: 'dashboard' }
      },
      {
        path: 'EmployeeHome/type1',
        component: () => import('@/views/ThreeEdition/EmployeeJump/type1'),
        name: 'EmployeeHomeType1',
        hidden: true,
        meta: { title: '2025XXX行动', icon: 'dashboard' }
      },
      {
        path: 'EmployeeHome/type2',
        component: () => import('@/views/ThreeEdition/EmployeeJump/type2'),
        name: 'EmployeeHomeType2',
        hidden: true,
        meta: { title: '2025XXX行动', icon: 'dashboard' }
      },
      {
        path: 'EmployeeHome/type3',
        component: () => import('@/views/ThreeEdition/EmployeeJump/type3'),
        name: 'EmployeeHomeType3',
        hidden: true,
        meta: { title: '2025XXX行动', icon: 'dashboard' }
      },
      {
        path: 'EmployeeHome/type4',
        component: () => import('@/views/ThreeEdition/EmployeeJump/type4'),
        name: 'EmployeeHomeType4',
        hidden: true,
        meta: { title: '2025XXX行动', icon: 'dashboard' }
      },
      {
        path: 'ProjectEstablishment',
        component: () => import('@/views/ThreeEdition/index.vue'),
        name: 'ProjectEstablishment',
        meta: { title: '项目立项', icon: 'dashboard' },
        children: [
          {
            path: 'ProjectEstablishment',
            component: () => import('@/views/ThreeEdition/ProjectEstablishment.vue'),
            name: 'ProjectEstablishment',
            meta: { title: '项目立项', icon: 'dashboard' }
          },
          {
            path: 'ImportDetails',
            component: () => import('@/views/ThreeEdition/ImportDetails.vue'),
            name: 'ImportDetails',
            meta: { title: '导入明细', icon: 'dashboard' }
          }
        ]
      },
      {
        path: 'Tasklist',
        component: () => import('@/views/ThreeEdition/index.vue'),
        name: 'Tasklist',
        meta: { title: '任务列表', icon: 'dashboard' },
        children: [
          {
            path: 'Tasklist',
            component: () => import('@/views/ThreeEdition/Tasklist.vue'),
            name: 'Tasklist',
            meta: { title: '任务列表', icon: 'dashboard' }
          },
          {
            path: 'TasklistAdd',
            component: () => import('@/views/ThreeEdition/TasklistDialog/TasklistAdd.vue'),
            name: 'TasklistAdd',
            meta: { title: '任务列表添加', icon: 'dashboard' }
          },
          {
            path: 'TasklistAddC',
            component: () => import('@/views/ThreeEdition/TasklistDialog/TasklistAddC.vue'),
            name: 'TasklistAddC',
            meta: { title: '任务列表浏览', icon: 'dashboard' }
          },
          {
            path: 'ImportDetailsC',
            component: () => import('@/views/ThreeEdition/ImportDetailsC.vue'),
            name: 'ImportDetailsC',
            meta: { title: '明细浏览', icon: 'dashboard' }
          }
        ]
      },

      {
        path: 'Approval',
        component: () => import('@/views/Approval/Approval.vue'),
        name: 'Approval',
        meta: { title: '审批', icon: 'dashboard' }
      }
    ]
  },
  {
    path: '/Fourth',
    component: Layout,
    // meta: { title: '第四版', icon: 'dashboard' },
    children: [
      {
        path: 'LeaderHomeS',
        component: () => import('@/views/FourthEdition/LeaderHomeS.vue'),
        name: 'LeaderHomeS',
        meta: { title: '总经理首页', icon: 'dashboard', affix: true }
      },
      {
        path: 'LeaderHome',
        component: () => import('@/views/FourthEdition/LeaderHome.vue'),
        name: 'LeaderHome',
        meta: { title: '领导首页', icon: 'dashboard', affix: true }
      },
      {
        path: 'SupervisorHome',
        component: () => import('@/views/FourthEdition/SupervisorHome.vue'),
        name: 'DepLeaderHome',
        meta: { title: '督办首页', icon: 'dashboard', affix: true }
      },
      {
        path: 'ProjectEstablishment',
        component: () => import('@/views/FourthEdition/index.vue'),
        name: 'ProjectEstablishment',
        // meta: { title: '立项', icon: 'dashboard' },
        children: [
          {
            path: 'ProjectEstablishment',
            component: () => import('@/views/FourthEdition/ProjectEstablishment.vue'),
            name: 'ProjectEstablishment',
            meta: { title: '立项管理', icon: 'dashboard' }
          },
          {
            path: 'ProjectEstablishment2',
            component: () => import('@/views/FourthEdition/ProjectEstablishment2.vue'),
            name: 'ProjectEstablishment2',
            meta: { title: '立项管理2', icon: 'dashboard' }
          },
          {
            path: 'ImportDetails',
            component: () => import('@/views/FourthEdition/ImportDetails.vue'),
            name: 'ImportDetails',
            meta: { title: '导入明细', icon: 'dashboard' },
            hidden: true
          }
        ]
      },

      {
        path: 'DepLeaderHome',
        component: () => import('@/views/FourthEdition/DepLeaderHome.vue'),
        name: 'DepLeaderHome',
        meta: { title: '部门领导首页', icon: 'dashboard', affix: true }
      },
      {
        path: 'EmployeeHome',
        component: () => import('@/views/FourthEdition/EmployeeHome.vue'),
        name: 'EmployeeHome',
        meta: { title: '主任首页', icon: 'dashboard', affix: true }
      },
      {
        path: 'FillOutHome',
        component: () => import('@/views/FourthEdition/FillOutHome.vue'),
        name: 'FillOutHome',
        meta: { title: '首页', icon: 'dashboard', affix: true }
      },
      {
        path: 'EmployeeHome/type1',
        component: () => import('@/views/FourthEdition/EmployeeJump/type1'),
        name: 'EmployeeHomeType1',
        hidden: true,
        meta: { title: '审批', icon: 'dashboard' }
      },
      {
        path: 'EmployeeHome/type2',
        component: () => import('@/views/FourthEdition/EmployeeJump/type2'),
        name: 'EmployeeHomeType2',
        hidden: true,
        meta: { title: '拆分', icon: 'dashboard' }
      },
      {
        path: 'EmployeeHome/type3',
        component: () => import('@/views/FourthEdition/EmployeeJump/type3'),
        name: 'EmployeeHomeType3',
        hidden: true,
        meta: { title: '审批', icon: 'dashboard' }
      },
      {
        path: 'EmployeeHome/type4',
        component: () => import('@/views/FourthEdition/EmployeeJump/type4'),
        name: 'EmployeeHomeType4',
        hidden: true,
        meta: { title: '审批', icon: 'dashboard' }
      },

      {
        path: 'Tasklist',
        component: () => import('@/views/FourthEdition/index.vue'),
        name: 'Tasklist',
        // meta: { title: '任务列表', icon: 'dashboard' },
        children: [
          {
            path: 'Tasklist',
            component: () => import('@/views/FourthEdition/Tasklist.vue'),
            name: 'Tasklist',
            meta: { title: '任务列表', icon: 'dashboard' }
          },
          {
            path: 'TasklistAdd',
            component: () => import('@/views/FourthEdition/TasklistDialog/TasklistAdd.vue'),
            name: 'TasklistAdd',
            meta: { title: '任务列表添加', icon: 'dashboard' },
            hidden: true
          },
          {
            path: 'TasklistAddC',
            component: () => import('@/views/FourthEdition/TasklistDialog/TasklistAddC.vue'),
            name: 'TasklistAddC',
            meta: { title: '任务列表浏览', icon: 'dashboard' },
            hidden: true
          },
          {
            path: 'ImportDetailsC',
            component: () => import('@/views/FourthEdition/ImportDetailsC.vue'),
            name: 'ImportDetailsC',
            meta: { title: '明细浏览', icon: 'dashboard' },
            hidden: true
          }
        ]
      },
      {
        path: 'FourthApproval1',
        component: () => import('@/views/Approval/FourthApproval1.vue'),
        name: 'FourthApproval1',
        meta: { title: '审批1', icon: 'dashboard' }
      },
      {
        path: 'FourthApproval2',
        component: () => import('@/views/Approval/FourthApproval2.vue'),
        name: 'FourthApproval2',
        meta: { title: '审批2', icon: 'dashboard' }
      },
      {
        path: 'text',
        component: () => import('@/views/Approval/text.vue'),
        name: 'text',
        meta: { title: '审批3', icon: 'dashboard' }
      },

      {
        path: 'disposition',
        component: () => import('@/views/FourthEdition/index.vue'),
        name: 'disposition',
        // meta: { title: '配置信息', icon: 'dashboard' },
        children: [
          {
            path: 'caidan',
            name: 'caidan',
            component: () => import('@/views/peizhixinxi/caidan.vue'),
            meta: { title: '菜单管理', icon: 'dashboard' }
          },
          {
            path: 'shenpimoban',
            name: 'shenpimoban',
            component: () => import('@/views/peizhixinxi/shenpimoban.vue'),
            meta: { title: '审批模板', icon: 'dashboard' }
          }
        ]
      },
      {
        path: 'Foundation',
        component: () => import('@/views/FourthEdition/index.vue'),
        name: 'Foundation',
        // meta: { title: '基础信息', icon: 'dashboard' },
        children: [
          {
            path: 'zidianweih',
            name: 'zidianweih',
            component: () => import('@/views/jichuxinxi/zidianweih.vue'),
            meta: { title: '字典维护', icon: 'dashboard' }
          },
          {
            path: 'zuzhirenyuan',
            name: 'zuzhirenyuan',
            component: () => import('@/views/FourthEdition/index.vue'),
            meta: { title: '组织人员', icon: 'dashboard' },
            children: [
              {
                path: 'bumen',
                name: 'bumen',
                component: () => import('@/views/jichuxinxi/zuzhirenyuan/bumen.vue'),
                meta: { title: '部门管理', icon: 'dashboard' }
              },
              {
                path: 'gangwei',
                name: 'gangwei',
                component: () => import('@/views/jichuxinxi/zuzhirenyuan/gangwei.vue'),
                meta: { title: '岗位信息', icon: 'dashboard' }
              },
              {
                path: 'renyuan',
                name: 'renyuan',
                component: () => import('@/views/jichuxinxi/zuzhirenyuan/renyuan.vue'),
                meta: { title: '人员管理', icon: 'dashboard' }
              },
              {
                path: 'denglurenyuan',
                name: 'denglurenyuan',
                component: () => import('@/views/jichuxinxi/zuzhirenyuan/denglurenyuan.vue'),
                meta: { title: '登录人员', icon: 'dashboard' }
              },
              {
                path: 'juese',
                name: 'juese',
                component: () => import('@/views/jichuxinxi/zuzhirenyuan/juese.vue'),
                meta: { title: '角色管理', icon: 'dashboard' }
              }
            ]
          }
        ]
      }
    ]
  }
]

const createRouter = () =>
  new Router({
    // mode: 'history', // require service support
    scrollBehavior: () => ({ y: 0 }),
    routes: constantRoutes
  })

const router = createRouter()

export function resetRouter() {
  const newRouter = createRouter()
  router.matcher = newRouter.matcher // reset router
}

export default router
